
#define _HAS_CXX17 1
#include <Eventer.h>
#include <iostream>
void main() {
	xc::Event<int, int> a;
	auto callback1 = a.onTrigger([](int, int) {
		std::cout << "1" << std::endl;
	});
	auto callback2 = a.onTrigger([](int, int) {
		std::cout << "2" << std::endl;
	});
	a.remove(callback2);
	a.broadcast(1, 2);

	xc::ThreadEvent<int> b;
	b.onTrigger([](int a) {
		std::cout << a<<a<<a<<a << std::endl;
	});
	bool a1 = false, a2 = false, a3=false;
	std::thread t([&]() {
		for (int i = 0; i < 10; ++i){
			std::this_thread::sleep_for(std::chrono::milliseconds(30));
			b.broadcast(2);
		}
		a1 = true;
	});
	std::thread t2([&]() {
		for (int i = 0; i < 10; ++i) {
			std::this_thread::sleep_for(std::chrono::milliseconds(20));
			b.broadcast(3);
		}
		a2 = true;
	});
	std::thread t1([&]() {
		for (int i = 0; i < 10; ++i) {
			std::this_thread::sleep_for(std::chrono::milliseconds(10));
			b.broadcast(5);
		}
		a3 = true;
	});
	t1.join();
	t2.join();
	t.join();
	b.flush();
}